<?php

namespace app\lmsx\validate;
use think\Validate;
use think\Db;

/**
 * 指派识别码验证
 * @author lan
 */
class Code extends Validate
{
    //定义验证规则
    protected $rule = [
        'user_id|用户'  => 'require|CheckUser:thinkphp',
    ];

    //定义验证提示
    protected $message = [
    ];

    protected function CheckUser($value,$rule){
        $row=Db::table('dp_lmsx_code')->where(['user_id'=>$value])->find();
        if(empty($row)){
            return $rule=true;
        }
        return $rule='该用户已经指派识别码';
    }
}
